/***
 * This class represents the an occurrence or occurrences of a particular word in a particular file 
 * 
 */

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;


public class WordInFileIndexInstance {

	public FileIndexInstance file;
	private List lineNumberList;
	
	/**
	 * Links a file and a word together to create a new instance
	 * @param file
	 * @param word
	 */
	public WordInFileIndexInstance(FileIndexInstance file, WordIndexInstance word)
	{
		this.file=file;
		lineNumberList=new LinkedList();
	}
	
	/**
	 * Adds a line number for this word/file match.
	 * @param lineNum
	 */
	public void addLineNumber(int lineNum)
	{
		if (lineNum>0)
		lineNumberList.add(new Integer(lineNum));
	}
	/**
	 * Gets an iterator for the line number of this pairing
	 * @return
	 */
	public Iterator getLineNumberIterator()
	{
		return lineNumberList.listIterator();
	}
	
	/**
	 * Overrides the hashCode to return the hashcode of the file.
	 * This is used in WordInstance to distinguish between different files for a particular word.
	 */
	public int hashCode()
	{
		return file.hashCode();
	}
}
